package cdc.retrofit.official.jsonqueryparameters;

import java.io.IOException;

import okhttp3.RequestBody;
import okio.Buffer;
import retrofit2.Converter;

public class DelegateToStringConverter<T> implements Converter<T, String> {
	private final Converter<T, RequestBody> delegate;

	DelegateToStringConverter(Converter<T, RequestBody> delegate) {
		this.delegate = delegate;
	}

	@Override
	public String convert(T value) throws IOException {
		Buffer buffer = new Buffer();
		delegate.convert(value).writeTo(buffer);
		return buffer.readUtf8();
	}
}
